const state = {
  systemDictData:{
  }
}

const mutations = {
  UPDATE_DICT_DATA: (state, data) => {
    if ( data.dictType === null || typeof data.dictType !== 'string' ||  data.dictType === ''){
      return
    }
    if (data.dictData instanceof Array && data.dictData.length>0){
      state.systemDictData[data.dictType] = data.dictData
    }
  },
  DELETE_DICT_DATA: (state, dictType) => {
    if ( dictType === null || typeof dictType !== 'string' ||  dictType === ''){
      return
    }
    delete state.systemDictData[dictType]
  }
}

const actions = {
  updateDictData({ commit }, data) {
    commit('UPDATE_DICT_DATA', data)
  },
  deleteDictData({ commit }, dictType) {
    commit('DELETE_DICT_DATA', dictType)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
